#include "CNotifyMgr.h"
#include "../cmdinner/CCmdNotify.h"
#include "../mainctrl.h"
#include "commmsg.h"

int CNotifyMgr::Notify(unsigned int uiGID, unsigned int uiNotifyType, unsigned int uiPara1)
{
    if (uiGID == 0)
    {
        return 0;
    }

    if (uiNotifyType == 0)
    {
        return 0;
    }

    CCmdNotify* pstCmd = (CCmdNotify*)CT_CMDFACTORY->CreateCmd(ID_MAIN_NOTIFY);
    if (pstCmd == NULL)
    {
        CT_ERROR(("create CCmdNotify error"));
        return RET_SYSTEM_FAIL;
    }

    pstCmd->pstMainCtrl = CMainCtrl::m_pstMain;
    pstCmd->uiGID = uiGID;
    pstCmd->uiPara1 = uiPara1;
    pstCmd->SetNotifyType(uiNotifyType);

    return pstCmd->Do(NULL);
}

void CNotifyMgr::SendTips(unsigned int uiGID, unsigned int uiTipsType)
{
    PBMsgHead stTipMsgHead;
    stTipMsgHead.set_msgid(ID_MAIN_TIPS);
    stTipMsgHead.set_msgtype(CSMsgDef::EMT_ANSWER);
    stTipMsgHead.set_msgact(0);

    MsgTips stTips;
    stTips.set_type(uiTipsType);
    CMainCtrl::m_pstMain->m_stEncodeBuf.Clear();
    CMainCtrl::m_pstMain->EncodePBMsg(stTipMsgHead, CMainCtrl::m_pstMain->m_stEncodeBuf);
    CMainCtrl::m_pstMain->EncodePBMsg(stTips, CMainCtrl::m_pstMain->m_stEncodeBuf);
    CMainCtrl::m_pstMain->NotifyOnlineUser (uiGID, CMainCtrl::m_pstMain->m_stEncodeBuf);
}


